package com.zhoug.share3demo;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.Button;

import com.zhoug.share3.ShareCallback;
import com.zhoug.share3.ShareParams;
import com.zhoug.share3.ui.ShareDialog;
import com.zhoug.share3.ui.ShareView;

public class MainActivity extends MyBaseActivity {
    private Button mBtnShare;
    private ShareView mShareView;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_main;
    }

    @Override
    protected void findViews() {

        mBtnShare = findViewById(R.id.btn_share);
        mShareView = findViewById(R.id.shareView);
    }

    @Override
    protected void onCreate1(Bundle savedInstanceState) {
        mBtnShare.setOnClickListener(v->{
            ShareDialog shareDialog=new ShareDialog(this);
            shareDialog.setClientFlag(ShareDialog.CLIENT_ALL);
            shareDialog.setShareCallback(new ShareCallback() {
                @Override
                public void onKeepLocalSuccess(String keepPath) {
                    toast(keepPath);
                }

                @Override
                public void onShareError(Throwable error) {
                    toast(error.getMessage());
                }
            });
            Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.test_share_img);
            ShareParams shareParams=new ShareParams();
            shareParams.setShareType(ShareParams.SHARE_TYPE_IMAGE);
            shareParams.setImageData(bitmap);
            shareDialog.setShareParams(shareParams);
            shareDialog.show();

        });
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.test_share_img);

        mShareView.setClientFlag(ShareView.CLIENT_ALL);
        ShareParams shareParams=new ShareParams();
        shareParams.setShareType(ShareParams.SHARE_TYPE_IMAGE);
        shareParams.setImageData(bitmap);
        mShareView.setShareParams(shareParams);
        mShareView.init();


    }
}